-
Notifications
You must be signed in to change notification settings - Fork 67
feat: add list secret names tool and api for dotenv files #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This PyAirbyte VersionYou can test this version of PyAirbyte using the following: # Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@aj/feat/list-dotenv-secret-keys' pyairbyte --help
# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@aj/feat/list-dotenv-secret-keys' Helpful ResourcesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
Community SupportQuestions? Join the #pyairbyte channel in our Slack workspace. |
📝 WalkthroughWalkthroughAdds DotenvSecretManager.list_secrets_names() and a new helper list_dotenv_secrets() that discovers DotenvSecretManager instances, reads each manager's dotenv keys, and returns a mapping from dotenv filename to list of secret names. The helper is exported via register_local_ops_tools. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant Locator as secret sources
participant DM as DotenvSecretManager
Note over Caller,Locator: Caller invokes list_dotenv_secrets()
Caller->>Locator: get secret sources
loop for each source
Locator->>DM: identify DotenvSecretManager instances
alt has dotenv_path
DM->>DM: list_secrets_names() reads dotenv_values
DM-->>Caller: return list of keys
else no dotenv_path
DM-->>Caller: skip
end
end
Note over Caller: returns dict(filename -> [keys])
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Would you like a short unit-test checklist for these additions, wdyt? Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
airbyte/secrets/env_vars.py (1)
66-71
: Harden.env
parsing and return a stable order (optional: rename tolist_secret_names
)To keep behavior consistent with
get_secret()
(which swallows parse/missing-file errors) and to make outputs deterministic for tests/UI, could we wrap parsing in try/except and sort the keys? Also, would you consider the singular formlist_secret_names
for readability, then update callers, wdyt?Apply this diff:
- def list_secrets_names(self) -> list[str]: - """List all secrets available in the .env file.""" - dotenv_vars: dict[str, str | None] = dotenv_values( - dotenv_path=self.dotenv_path, - ) - return list(dotenv_vars.keys()) + def list_secrets_names(self) -> list[str]: + """List all secret variable names available in the .env file (names only, no values).""" + try: + dotenv_vars: dict[str, str | None] = dotenv_values( + dotenv_path=self.dotenv_path, + ) + except Exception: + # Can't locate or parse a .env file; align with get_secret() behavior + return [] + return sorted(dotenv_vars.keys())If you prefer the rename, here’s the alternative within this file:
- def list_secrets_names(self) -> list[str]: + def list_secret_names(self) -> list[str]:And the corresponding call-site update is proposed in
airbyte/mcp/_local_ops.py
below.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
airbyte/mcp/_local_ops.py
(2 hunks)airbyte/secrets/env_vars.py
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
airbyte/mcp/_local_ops.py (2)
airbyte/secrets/env_vars.py (3)
DotenvSecretManager
(31-71)name
(37-41)list_secrets_names
(66-71)airbyte/secrets/config.py (1)
_get_secret_sources
(16-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Pytest (All, Python 3.11, Windows)
- GitHub Check: Pytest (All, Python 3.11, Ubuntu)
- GitHub Check: Pytest (All, Python 3.10, Ubuntu)
- GitHub Check: Pytest (All, Python 3.10, Windows)
- GitHub Check: Pytest (No Creds)
- GitHub Check: Pytest (Fast)
🔇 Additional comments (1)
airbyte/mcp/_local_ops.py (1)
18-18
: Import looks goodImporting
DotenvSecretManager
here is appropriate for the type check in the new helper. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
airbyte/mcp/_local_ops.py (3)
188-200
: Harden + make output deterministic (sort + guard errors).Could we sort the names and guard against dotenv parsing errors so callers get stable, non-throwing results, wdyt?
Apply this diff:
def list_dotenv_secrets() -> dict[str, list[str]]: - """List all environment variable names declared within declared .env files. - - This returns a dictionary mapping the .env file name to a list of environment - variable names. The values of the environment variables are not returned. - """ + """List environment variable names declared in configured .env files. + + Returns: mapping of absolute .env file path -> sorted list of variable names (names only; no values). + """ result: dict[str, list[str]] = {} for secrets_mgr in _get_secret_sources(): if isinstance(secrets_mgr, DotenvSecretManager) and secrets_mgr.dotenv_path: - result[str(secrets_mgr.dotenv_path.resolve())] = secrets_mgr.list_secrets_names() + key = str(secrets_mgr.dotenv_path.resolve()) + try: + names = secrets_mgr.list_secrets_names() + except Exception: + names = [] + result[key] = sorted(names) return result
189-193
: Docstring mismatch with behavior.Doc says “file name” but the key is an absolute path; also phrasing repeats “declared”. Mind updating to reflect absolute paths and simplify wording, wdyt?
Apply this docstring-only diff if you prefer a minimal change:
- """List all environment variable names declared within declared .env files. - - This returns a dictionary mapping the .env file name to a list of environment - variable names. The values of the environment variables are not returned. - """ + """List environment variable names declared in configured .env files. + + Returns a mapping of absolute .env file path to a list of variable names (names only; no values). + """
194-199
: Check comfort level with exposing absolute paths.Using absolute paths as keys can surface local usernames or workspace structure in UIs/logs. Is that acceptable for this tool, or should we consider masking (e.g., Path.name, relative-to-CWD, or a “display_name” field) while keeping the absolute path in a separate “path” field, wdyt?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
airbyte/mcp/_local_ops.py
(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
airbyte/mcp/_local_ops.py (2)
airbyte/secrets/env_vars.py (2)
DotenvSecretManager
(31-71)list_secrets_names
(66-71)airbyte/secrets/config.py (1)
_get_secret_sources
(16-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Pytest (All, Python 3.11, Ubuntu)
- GitHub Check: Pytest (All, Python 3.11, Windows)
- GitHub Check: Pytest (All, Python 3.10, Ubuntu)
- GitHub Check: Pytest (All, Python 3.10, Windows)
- GitHub Check: Pytest (No Creds)
- GitHub Check: Pytest (Fast)
🔇 Additional comments (2)
airbyte/mcp/_local_ops.py (2)
18-18
: LGTM: needed import added.Importing DotenvSecretManager enables the isinstance guard below; looks good.
691-691
: Approve: list_dotenv_secrets registeredlist_dotenv_secrets is defined (airbyte/mcp/_local_ops.py:188) and registered in register_local_ops_tools (airbyte/mcp/_local_ops.py:691); no occurrences of the old name list_dotenv_secret_names remain — wdyt?
Summary by CodeRabbit
Important
Auto-merge enabled.
This PR is set to merge automatically when all requirements are met.